#override("title")
用户管理
#end
#override("body")
<body class="gray-bg">
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>标题</h2>
        <ol class="breadcrumb">
            <li>
                <a href="index-2.html">权限管理</a>
            </li>
            <li>
                <strong>用户管理</strong>
            </li>
        </ol>
    </div>
    <div class="col-sm-8">
        <div class="title-action">
            <a href="empty_page.html" class="btn btn-primary">活动区域</a>
        </div>
    </div>
</div>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <table id="dataTable"></table>
        </div>
    </div>
</div>
</body>
#end
#override("js")
<script type="text/javascript">
    var dataUrl = "#springUrl('/user/getUserList.html')";
    var dataColumns = [{
        field: 'id',
        title: '序号'
    }, {
        field: 'loginName',
        title: '登录名'
    }, {
        field: 'email',
        title: '邮箱'
    }, {
        field: 'type',
        title: '用户类型'
    }, {
        field: 'status',
        title: '状态'
    }, {
        field: 'crTime',
        title: '创建时间',
        formatter: function (value, row, index) {
            return formatDate(row.crTime);
        }
    }, {
        field: 'lastTime',
        title: '最后更新时间',
        formatter: function (value, row, index) {
            return formatDate(row.lastTime);
        }
    }, {
        title: '#',
        formatter: function (value, row, index) {
            var id = row.id;
            return '<a class="btn btn-xs btn-info" href="#springUrl('/user/addUser/0')"><i class="fa fa-pencil"></i>新增</a> '
                    +'<a class="btn btn-xs btn-info" onclick="editUser(' + "'" + id + "'" + ')"><i class="fa fa-pencil"></i>编辑</a> '
                    + '<a class="btn btn-xs btn-info" onclick="delUser(' + "'" + id + "'" + ')"><i class="fa fa-remove"></i>删除</a>';
        }
    }
    ];
    function dataQueryParams(params) {
        return {
            _size: params.limit,  //页面大小
            _index: params.offset, //页码
        };
    }

    function delUser(userId) {
        console.info(userId);
        //询问框
        layer.confirm('确定删除吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "POST",
                url: "#springUrl('/user/delUser/')" + userId,
                datatype: "text",
                success: function (data) {
                    if(data == 'true'){
                        $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                    }
                    layer.closeAll();
                }
            });
        }, function () {
            return;
        });
    }

    function editUser(userId,type){
        var title;
        if(type == 1){
            title = "新增用户";
        } else{
            title = "编辑用户";
        }
        //iframe层
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['540px', '600px'],
            fix: false, //不固定
            maxmin: true,
            //content: "http://www.baidu.com" //iframe的url
            content: "#springUrl('/user/addUser/1')" //iframe的url
        });
    }
</script>
#end
#extends("/common/base_list.html")
